package com.weipai.demo.util;


import com.weipai.demo.enums.RetCode;

import java.util.HashMap;
import java.util.Map;

/**
 * @author songmengqiang
 * @create 2018-08-21 17:11
 **/

public class Response {
    private String code;
    private String msg;

    private Object data = new HashMap<>();
    private Long count;

    public void put(String key, Object val) {
        if (data != null && data instanceof Map) {
            ((Map<String, Object>) data).put(key, val);
        }
    }

    @Override
    public String toString() {
        return "Response{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                ", count=" + count +
                '}';
    }

    public String getCode() {
        return code;
    }

    public void setCode(RetCode retCode) {
        this.code = retCode.getCode();
        this.msg = retCode.getMsg();
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Object getData() {
        return data;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }
}
